<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%
	String hospitalNotesJson= (String)request.getAttribute("hospitalNotesJson");
	String pageJson= (String)request.getAttribute("pageJson");
 %>
<script>
//浮动弹窗部分
/*$(function(){
window.onload = function ()
{
 var oWin = document.getElementById("win");
 var oLay = document.getElementById("overlay"); 
 var oClose = document.getElementById("close");
 var oH2 = oWin.getElementsByTagName("h2")[0];
 var bDrag = false;
 var disX = disY = 0;
 
 oClose.onclick = function ()
 {
  oLay.style.display = "none";
  oWin.style.display = "none";
  $("#phoneNumber").val("");
  $("#phoneNumber").val("");
   
 };
 oClose.onmousedown = function (event)
 {
  (event || window.event).cancelBubble = true;
 };
 oH2.onmousedown = function (event)
 {  
  var event = event || window.event;
  bDrag = true;
  disX = event.clientX - oWin.offsetLeft;
  disY = event.clientY - oWin.offsetTop;  
  this.setCapture && this.setCapture();  
  return false;
 };
 document.onmousemove = function (event)
 {
  if (!bDrag) return;
  var event = event || window.event;
  var iL = event.clientX - disX;
  var iT = event.clientY - disY;
  var maxL = document.documentElement.clientWidth - oWin.offsetWidth;
  var maxT = document.documentElement.clientHeight - oWin.offsetHeight;  
  iL = iL < 0 ? 0 : iL;
  iL = iL > maxL ? maxL : iL;   
  iT = iT < 0 ? 0 : iT;
  iT = iT > maxT ? maxT : iT;
   
  oWin.style.marginTop = oWin.style.marginLeft = 0;
  oWin.style.left = iL + "px";
  oWin.style.top = iT + "px";  
  return false;
 };
 document.onmouseup = window.onblur = oH2.onlosecapture = function ()
 {
  bDrag = false;    
  oH2.releaseCapture && oH2.releaseCapture();
 };
 $("#close").mouseover(function(){
			$("#close").addClass("changeCss");
		}).mouseout(function(){
			$("#close").removeClass("changeCss");
		});
};

});*/
</script>

<!--内容部分-->

<div class="list_NR ">
	<!--  <div id="overlay" class="overlay"></div>
	<div id="win" class="win">
	<h2><span id="close">×</span></h2>
		<table>
			<tr><td class="input_td">手机号:</td><td><input id="phoneNumber" style="margin-top: 20px;" class="input_text" type="text" title=''></td></tr>
			<tr><td class="input_td">短信内容:</td><td><input id="messageContent" class="input_text" type="text" title=''></td></tr>
			<tr><td></td><td><input type="button" class="input_submit" id="contentSubmit" onclick="VerificationContent()" value="催收"></td></tr>
		</table>
	</div>-->
    <div class="loc">
        <h3>未归病案查询-->催收</h3>
       <!--  <ul class="loc_loc">
          	  病案归档 > 病案催收
        </ul> -->
    </div>
     <form action="${basePath}/medrecord/urgeList" method="get" id="queryForm">
      <div class="list_con_table">
       
		<div class="search_table">
           <ul class="clearfix" style="margin-bottom:0;">

            <li class="Label_1" style="width:11%">出院日期：&nbsp;</li>
               <li class="Label_2" style="width:27%;">
                   <input style="width:43%;" class="input_box" name="outHospitalStartDate" value='<fmt:formatDate value="${medVisitUrgeQuery.outHospitalStartDate}" pattern="yyyy-MM-dd"/>' onFocus="WdatePicker()" type="text" > 
                   - <input style="width:43%" class="input_box" name="outHospitalEndDate"  value='<fmt:formatDate value="${medVisitUrgeQuery.outHospitalEndDate}" pattern="yyyy-MM-dd"/>' onFocus="WdatePicker()" type="text" >
               </li>
               <li class="Label_1" style="width:11%">ID号：&nbsp;</li>
               <li class="Label_2">
               	<input class="input_box" type="text"  id="scanBarCode" name="mrId" value='${medVisitUrgeQuery.mrId}' />
               </li>
               <li class="Label_1" style="width:11%">住院次数：&nbsp;</li>
               <li class="Label_2">
               	<input class="input_box" type="text" id="visitNumber"  name="visitNumber" value='${medVisitUrgeQuery.visitNumber}' />
               </li>
               <li class="Label_1" style="width:11%">身份证号：&nbsp;</li>
               <li class="Label_2" style="width:27%;"><input class="input_box" type="text"  name="idCard" id='' value='${medVisitUrgeQuery.idCard}' />
               	 
               </li>
               <li class="Label_1" style="width:11%">出院科室：&nbsp;</li>
               <li class="Label_2" style="text-align:left;padding-left:5px" >
               
               	<select class="input_box"  name="outHospitalOfficeId">
               		<option value="">请选择</option>
               		<c:forEach var="office" items="${offices }"> 
               			<option <c:if test="${medVisitUrgeQuery.outHospitalOfficeId==office.id}">selected="selected"</c:if> value="${office.id }">${office.name }</option>
               		</c:forEach>
                	
                	</select>
                	
                </li>
                <li class="Label_1" style="width:11%">患者名：&nbsp;</li>
               <li class="Label_2">
               	<input class="input_box" type="text"  name="name" value='${medVisitUrgeQuery.name }' />
               </li>
                <li class="Label_5">
                    <div class="right">
                    	<a id="Add" onclick="queryFormSubmit()">查询</a>
                    </div>
                </li>
            </ul>
        </div>
        <input type="hidden" id="byUrgeUserPhone" name="byUrgeUserPhone">
   </div>

   <table class="Search_tableList"cellpadding="0" cellspacing="0">

       <tr>
           <td class="tdLabel_4">姓名</td>
           <td class="tdLabel_4">身份证号</td>
           <td class="tdLabel_4">识别码</td>
            <td class="tdLabel_4">住院次数</td>
           <td class="tdLabel_4">出院日期</td>
           <td class="tdLabel_4">出院科室</td>
           <td class="tdLabel_4">离院方式</td>
           <td class="tdLabel_4">状态</td>
           <td class="tdLabel_4"><a onclick="urgeFormSubmit()" class="int" />催收</a></td>
       </tr>
      
       <tbody id="tbody" style="background-color: red;">
        </tbody>
    </table>
    </form>
</div>

<!--  <style>
	.changeCss{color: red;}
	.changeinputCss{border: 1px red solid;}
	.overlay{position:absolute;top:-138px;left:0px;background-color:#000;opacity:0.5;filter:alpha(opacity=50);display:none;}
	.win{position:absolute;top:130px;left:60%;width:400px;height:245px;background:#fff;margin:-102px 0 0 -202px;display:none;}
	h2{text-align:right;padding-right: 5px;margin-top: -3px;}
	h2 span{color:#000000;font-size:25;color:#000000;cursor:pointer;}
	.input_text{
		height: 38px;
		width: 240px;
		margin-bottom: 10px;
	}
	.input_td{
		padding-left: 38px;
	}
	.input_submit{
		height: 38px;
		width: 240px;
		background-color: #07a396;
		color: white;
		font-size: 18;
		font-family: 幼圆;
		border:none;
		text-align: center;
	}
</style>-->
<!--script JS部分-->
<script type="text/javascript" src="${basePath}/static/publics/assets/jquery/jquery.min.js"></script>
<script type="text/javascript" src="${basePath}/static/publics/assets/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="${basePath}/static/publics/assets/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="${basePath}/static/publics/assets/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/static/js/util.js"></script>
<script type="text/javascript">
	function queryFormSubmit(){
		var basePath = $("#basePath").val();
		$("#queryForm").attr("action",basePath +"/medrecord/urgeList");
		$("#queryForm").attr("method","get");
		$("#queryForm").submit();
	}
	
	
	$("#scanBarCode").change(function(){
		var $this=$(this);
		var inentity=$this.val();
		if(inentity!=null && inentity!='' && inentity!=undefined){
			if(isContainMark(inentity)){
				var mrId=inentity.split("-")[0];
				var visitNumber=inentity.split("-")[1];
				if(!isNumber(visitNumber)){
					alert("请重新扫描条形码!");
					$("#scanBarCode").val("").focus();
					$("#visitNumber").val("");
					return;
				}
				
				//alert(mrId+"--"+visitNumber);
				$("#scanBarCode").val("").val(mrId);
				$("#visitNumber").val("").val(visitNumber);
				$("#queryForm").submit();
			}
		}
	});
	
	function isNumber(value) {
	    var patrn = /^[0-9]*$/;
	    if (patrn.exec(value) == null || value == "") {
	        return false
	    } else {
	        return true
	    }
	}
	
	
	
	function isContainMark(inentity){
		var reg = RegExp(/-/);
		return reg.test(inentity);
	}
	
	function urgeFormSubmit(){
		var urgeGuids=document.getElementsByName("urgeGuids");
		var num=0;
		for(var i=0;i<urgeGuids.length;i++){
			if(urgeGuids[i].checked==true){
				num=1;
				break;
			}
		}
		if(num>0){
			//选中的催收病案进行操作
			for(var i=0;i<urgeGuids.length;i++){
				if(urgeGuids[i].checked==true){
					$(urgeGuids[i]).closest('td').prev("td").html("已催收");
				}
			}
			
			/*var htmlHeight=$('.list_NR').height();
			var htmlWidth=$('.list_NR').width();
			var left = $('html').css('left');
			var top = $('html').css('top');
			$(".overlay").css({
				height:htmlHeight,
				width:htmlWidth,
				left:left,
				top:top
			});
			$("#overlay").show();
			$("#win").show();*/
			/*
			var basePath = $("#basePath").val();
			$("#queryForm").attr("action",basePath +"/medrecord/urge");
			$("#queryForm").attr("method","post");
			 $("#queryForm").submit(); */
		}else{
			layer.alert("未选中被催收病案！", {icon: 0});
		}
	}
	
	
	
	/*function VerificationContent(){
		var phoneNumber=$("#phoneNumber").val();
		var messageContent=$("#messageContent").val();
		var num=0;
		$("[title='']").focus(function() { 
   			$("[title='']").each(function() {
   		  		$("[title='']").removeClass("changeinputCss");
   		  		
   			});
   	 	});
		
			
		$("[title='']").each(function() {  
              if ($(this).val()=="" || $(this).val()==null) {
                    $(this).addClass("changeinputCss");
                    num=1;
              }
		});
		if(num>0){
			//alert("手机号和短信内容不能为空!");
			layer.alert("手机号和短信内容不能为空!", {icon: 0});
			return;
		}
		
		if(regPhone(phoneNumber)==false){
			//alert("手机号码格式错误!");
			layer.alert("手机号码格式错误!", {icon: 0});
			$("#phoneNumber").addClass("changeinputCss");
			return;
		}
		
		$("#byUrgeUserPhone").val($("#phoneNumber").val());
		var oWin = document.getElementById("win");
 		var oLay = document.getElementById("overlay"); 
		oLay.style.display = "none";
  		oWin.style.display = "none";
  		$("#phoneNumber").val("");
  		$("#phoneNumber").val("");
  		var basePath = $("#basePath").val();
		$("#queryForm").attr("action",basePath +"/medrecord/urge");
		$("#queryForm").attr("method","post");
		$("#queryForm").submit();
	}*/

	$(function(){
		
		$("#scanBarCode").focus();	
	
		var data= <%=hospitalNotesJson%>;
		var page= <%=pageJson%>;
		var html ="";
		var basePath = $("#basePath").val();
		for(var i in data){
			var med=data[i];
			
			
			html+=med.warn_date_time==undefined?"<tr>":"<tr class='tr_font_red'>";
			html+="<td class='tdLabel_5'>"+(med.patient_name==undefined?'':med.patient_name)+"</td>"+
		                "<td class='tdLabel_5'>"+(med.id_number==undefined?'':med.id_number)+"</td>"+
		               " <td class=tdLabel_5>"+(med.mr_id==undefined?'':med.mr_id)+"</td>"+
		               " <td class=tdLabel_5>"+(med.visit_number==undefined?'':med.visit_number)+"</td>"+
		               " <td class=tdLabel_5>"+(med.out_hospital_date==undefined?'':med.out_hospital_date)+"</td>"+
		                "<td class='tdLabel_5'>"+(med.office_name==undefined?'':med.office_name)+"</td>"+
		               " <td class='tdLabel_5'>"+(med.out_hospital_type_name==undefined?'':med.out_hospital_type_name)+"</td>"+
		               " <td class='tdLabel_5'>"+(med.warn_date_time==undefined?'未催收':'已催收')+"</td>"+
		               " <td class='tdLabel_5'><a class='int' data-guid='"+med.first_level_guid+"' onclick='scan(this)'>查看患者数据</a>&nbsp;<input type='checkbox' name='urgeGuids' class='check_cl' value='"+med.first_level_guid+"' /></td>"
		}
		$("#tbody").html(html);
	});
	
	//查看数据病案事件
    function scan(obj){
		 var target=$(obj);
		 var guid=target.attr("data-guid");
		// window.open('${corePath}/medical_record/searchHomePageIndexForm?visitGuid='+guid);
		 window.open('${corePath}/medical_record/searchHomePageIndexForm?visitGuid='+guid);
	 }
</script>